package com.yonyou.pmclouds.workquality.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.exception.BuziExCodeConst;
import com.yonyou.pmclouds.workquality.entity.WorkqualityVO;
import com.yonyou.pmclouds.workquality.mapper.WorkqualityMapper;

/**
 * 缺少引用校验需要后期添加
 */
public class WorkqualityUpdateCheckProcessor implements SingleProcessor<WorkqualityVO> {

    private WorkqualityMapper mapper;

    public WorkqualityUpdateCheckProcessor(WorkqualityMapper mapper)
    {
        this.mapper = mapper;
    }
    @Override
    public void process(WorkqualityVO vo, WorkqualityVO orig) throws BusinessException {

        WorkqualityVO checkvo = new WorkqualityVO();
        checkvo.setCheckname(vo.getCheckname());
        checkvo.setDr((byte)0);
        checkvo.setPkWorkquality(vo.getPkWorkquality());
        Integer count = mapper.checkUpdateRepeat(checkvo);
        if(count!=null&&count>0)
        {
            throw new BusinessException("已经存在相同的编码，请修改!", BuziExCodeConst.CODE_CODE_DUPLICATE);
        }
    }
}
